home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
10,000 Great Games
/
10,000 Great Games.iso
/
Product
/
66
/
data1.cab
/
Source_Files
/
Src
/
Struct.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2000-01-16
|
1KB
|
68 lines
#include "stdafx.h"
cStructure *structures = 0, *structures_belowscreen = 0, *structures_abovescreen = 0;
cStructure::cStructure(int _x, int _y, cProperties *_orig, char *startseq)
: cGameObject(_orig)
{
add_end((cList **)&structures);
set_sequence(startseq, TRUE);
set_position(_x, _y);
inpenetrable = orig->params->get_bool("*INPENETRABLE", FALSE);
}
cStructure::~cStructure()
{
}
int cStructure::control()
{
cGameObject::control();
return !explode && !below_screen();
}
int cStructure::check_inpenetrable(cMovable *m, cDisplayable *d, cCircle *mc, cCircle *sc)
{
cStructure *s = (cStructure *)d;
cGameObject *g = (cGameObject *)m;
fix x = g->fx, y = g->fy;
// Check if structure is inpenetrable
if (!s->inpenetrable || !g->influenced_by_inpenetrable)
return FALSE;
// Check motion
if (g->x == g->ox && g->y == g->oy)
{
if (g->x > s->x)
x += 5;
else
x -= 5;
}
else
{
if (g->x != g->ox)
{
x = g->ox;
g->vx = -g->vx / g->bounce_loss;
}
if ((!g->fall_through_inpenetrable && g->y != g->oy)
|| (g->fall_through_inpenetrable && g->y > g->oy))
{
y = g->oy;
g->vy = 0;
}
}
g->set_position(x, y);
return TRUE;
}